//
//  ZCmainCell.m
//  zctx
//
//  Created by Yi luqi on 15/10/7.
//  Copyright © 2015年 sanliang. All rights reserved.
//

#import "ZCSamplingCell.h"
#import "ZCInvolvedModel.h"

@implementation ZCSamplingCell

- (void)awakeFromNib {
    // Initialization code
    self.nameLable.textColor = [UIColor colorWithHexString:@"#000000"];
    
    self.productiondataLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
    self.productionLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
    
    self.testdataLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
    self.testLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
    
    self.adressLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
    self.adressdetailLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
}

-(void)setSamplingModel:(ZCInvolvedModel *)samplingModel{
    _samplingModel = samplingModel;
    
    //名称
    self.nameLable.text =[NSString stringWithFormat:@"%@",samplingModel.pjname];
    
    //生产日期/批号
    if (samplingModel.batch.length>0) {
        self.productiondataLable.text = [NSString stringWithFormat:@"%@",samplingModel.batch];
    }else{
        self.productiondataLable.text =@"";
    }
    //检测日期
    if (samplingModel.testingDate.length>0) {
//        int timeInt =[samplingModel.testingDate intValue];
//        self.testdataLable.text = [NSString stringWithFormat:@"%@",dateTimeWithNString(timeInt)];
        self.testdataLable.text = samplingModel.testing_result;
    }else{
        self.testdataLable.text =@"";
    }
    self.testdataLable.textColor = [UIColor redColor];
    //抽样地
    if (samplingModel.location.length>0) {
        self.adressdetailLable.text = [NSString stringWithFormat:@"%@",samplingModel.location];
    }else{
        self.adressdetailLable.text =@"";
    }
    
    NSURL *url =[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[NetworkManager strURLBasic],samplingModel.thumb]];
    [self.ImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placehold_involved"]];
    NSString *result =[NSString stringWithFormat:@"%@",samplingModel.result];
    NSString *stateStr = [NSString stringWithFormat:@"%@",samplingModel.state];
    
    if ([result isEqualToString:@"0"]) {
        //未知情况 0 审核中  2 抽样中 3完成 4 异常
        if ([stateStr isEqualToString:@"0"]) {
            [self.stateImgView setImage:[UIImage imageNamed:@"search_examine"]];
        }else{
            [self.stateImgView setImage:[UIImage imageNamed:@"search_sampling"]];
        }
    }else if ([result isEqualToString:@"1"]){
        //合格
        [self.stateImgView setImage:[UIImage imageNamed:@"search_yes"]];
    }else{
        //不合格
        [self.stateImgView setImage:[UIImage imageNamed:@"search_no"]];
    }
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
